package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    @Select("select count(id) from dish where category_id = #{id}")
    Integer queryById(Long id);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> select(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    @Delete("delete from dish where id = #{id}")
    void removeById(Long id);


    void removeBatch(List<Long> ids);

    @Select("select *from dish where id = #{id} ")
    Dish selectById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);


    List<Long> selectSetmealByDishId(Long id);

    @Select("select *from dish where category_id = #{categoryId} and status = 1 ")
    List<Dish> selectByCategoryId(Long categoryId);

    List<DishVO> select_user(Dish dish);
}
